-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Editor: Update Block Editor classNames to convention #14420
Conversation
It took all of 20 minutes for this to receive its first merge conflict 😩 |
216328f
to
bdad16a
Compare
More notes:
|
Looks like there's a valid e2e test failure but yeah let's not let this PR linger too much, so I'm approving. |
The current failure is related to a few
These shouldn't be assigned here, and could probably be abstracted to a component offered by cc @ellatrix |
The above prompted me to do another search pass for the "editor-" plaintext term across all packages excluding There are several other erroneous occurrences:
gutenberg/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js Line 21 in 776c0e1
gutenberg/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js Line 93 in 776c0e1
gutenberg/packages/edit-post/src/components/visual-editor/block-inspector-button.js Line 39 in 776c0e1
As seen, they're all related to the format toolbar and block settings menu. Noted previously,
|
776c0e1
to
790fa23
Compare
Another useful pattern for auditing
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we should consider in a subsequent pull request is performing an audit of excessive code line length, refactoring some of the very-long lines made yet-further-longer as of the changes here.
@@ -23,8 +23,8 @@ class BlockCompare extends Component { | |||
|
|||
return difference.map( ( item, pos ) => { | |||
const classes = classnames( { | |||
'editor-block-compare__added': item.added, | |||
'editor-block-compare__removed': item.removed, | |||
'editor-block-compare__added block-editor-block-compare__added': item.added, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of my own curiosity, I did confirm that classnames
is capable of handling the assigning of two classes with respect to a single boolean property:
⇒ node
> var cn = require( 'classnames' )
undefined
> cn( { 'foo bar': true } )
'foo bar'
@@ -1,4 +1,4 @@ | |||
.editor-visual-editor__block[data-type="core/nextpage"] { | |||
.block-editor-block-list__block[data-type="core/nextpage"] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that this was previously very broken, .editor-visual-editor__block
doesn't exist anywhere before or after this set of changes. It should be corrected here now.
Previously: #14112
This nightmare of a pull request seeks to update class names for components moved from the
editor
package toblock-editor
, in order to continue respecting the CSS class naming guidelines which prescribe that each component be prefixed by its package directory. It does so without breaking compatibility by keeping the.editor-
prefix as a compatibility mechanism.In its current incarnation, it is as conservative as possible to keeping full compatibility. Unlike my previous comment by which I'd jynxed myself, automated transforms are highly fraught with issues (dealing with
classnames
, string template interpolation, etc). Conversely, I chose not to get into specifics of what's "worth" keeping for compatibility, for the sake of keeping the effort short-lived and as non-contentious as possible. In both of these instances, I think revisiting in the future may be appropriate.There is an argument to be made that we make a specific exception to the CSS naming guidelines for the
block-editor
module, allowing botheditor
andblock-editor
components to share theeditor-
prefix for the sake of avoiding this tedious transition. My cautions against this are that (a) exceptions are bad because they break expectations and (b) it introduces the risk of unintentional conflict when working with components across the two otherwise distinct modules.Implementation notes:
The changes here were partly RegEx-assisted mass string replacements, with a supplementary (sometimes involved) manual curation.
Specific replacement patterns:
(['"])editor-(?!aligncenter|alignleft|alignright|bold|break|code|contract|customchar|expand|help|indent|insertmore|italic|justify|kitchensink|ltr|ol-rtl|ol|outdent|paragraph|paste-text|paste-word|quote|removeformatting|rtl|spellcheck|strikethrough|table|textcolor|ul|underline|unlink|video)([^ '"]+)
$1editor-$2 block-editor-$2
editor-
(example)editor-
occurrence for functions expecting a singular argument(hasClass|contains)\( 'editor-.*?
$1( '
editor-
occurrence for IDs(id|htmlFor|aria-.+?)(="|': ')editor-.*?
$1$2
\.editor-(autocomplete|alignment-toolbar|block-alignment-toolbar|block-controls|block-edit|block-format-controls|block-icon|block-inspector|block-list|block-mover|block-navigation-dropdown|block-selection-clearer|block-settings-menu|block-title|block-toolbar|color-palette|contrast-checker|copy-handler|default-block-appender|inserter|inner-blocks|inspector-advanced-controls|inspector-controls|panel-color-settings|plain-text|rich-text|media-placeholder|media-upload|multi-blocks-switcher|multi-select-scroll-into-view|navigable-toolbar|observe-typing|preserve-scroll-in-reorder|skip-to-selected-block|url-input|url-popover|warning|writing-flow)
.block-editor-$1
.editor-
were manually performed (guided in some cases by "post" exception\.editor-(?!post-)
).Notable exceptions:
Testing Instructions:
Give it a thorough shake, paying very close attention to visual regressions.
End-to-end tests should also reveal some issues, if present.
Most useful review will be in considering what may have been overlooked or wrongly revised.